from concurrent import futures
from rpc_server.protobuf import Stocks_pb2_grpc as StocksGrpc, Genes_pb2_grpc as GenesGrpc
import rpc_server.stocks as stocks
import rpc_server.genes as genes
import grpc


def grpc_serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    StocksGrpc.add_StocksServiceServicer_to_server(stocks.StocksServiceImpl(), server)
    GenesGrpc.add_GenesServiceServicer_to_server(genes.GenesService(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    server.wait_for_termination()
